/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package other;

import B3D_Elements.B3D_Element;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
 *
 * @author David
 */
public class ElementList implements Serializable
{

    private HashMap<B3D_Elements.B3D_Element, Object> elementHashMap = new HashMap<B3D_Element, Object>();
    private HashMap<Object, B3D_Elements.B3D_Element> objectHashMap = new HashMap<Object, B3D_Elements.B3D_Element>();

    public void putByElement(B3D_Element element, Object object)
    {
        elementHashMap.put(element, object);
        objectHashMap.put(object, element);
    }

    public void putByObject(Object object, B3D_Element element)
    {
        elementHashMap.put(element, object);
        objectHashMap.put(object, element);
    }

    public void removeByElement(B3D_Element element)
    {
        Object object = elementHashMap.get(element);
        objectHashMap.remove(object);
        elementHashMap.remove(element);
    }

    public void removeByObject(Object object)
    {
        B3D_Element element = objectHashMap.get(object);
        objectHashMap.remove(object);
        elementHashMap.remove(element);
    }

    public B3D_Element getElement(Object object)
    {
        return objectHashMap.get(object);
    }

    public B3D_Element getElement(UUID uuid)
    {
        for (Map.Entry<B3D_Element, Object> entry : elementHashMap.entrySet())
        {
            if (uuid.equals(entry.getKey().getID()))
            {
                return entry.getKey();
            }
        }
        return null;
    }

    public Object getObject(UUID uuid)
    {
        for (Map.Entry<B3D_Element, Object> entry : elementHashMap.entrySet())
        {
            if (uuid.equals(entry.getKey().getID()))
            {
                return entry.getValue();
            }
        }
        return null;
    }

    public Object getObject(B3D_Element element)
    {
        return elementHashMap.get(element);
    }

    public HashMap<B3D_Element, Object> getElementHashMap()
    {
        return elementHashMap;
    }

    public HashMap<Object, B3D_Element> getObjectHashMap()
    {
        return objectHashMap;
    }
}
